﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EntityLayer;
namespace DataLayer.DAO
{
    public class clsUnidOrgDAO
    {
        private BD_LEGAJOEntities ContextoDeObjs = new BD_LEGAJOEntities();
        public bool Insertar(PRM_UNI_ORGANICA Obj)
        {
            try
            {
                ContextoDeObjs.AddObject("PRM_UNI_ORGANICA", Obj);
                ContextoDeObjs.SaveChanges();
                return true;
            }
            catch (Exception)
            {
                return false;
                throw;
            }
        }
        public bool Modificar(PRM_UNI_ORGANICA obj)
        {

            try
            {
                ContextoDeObjs.AttachTo("PRM_UNI_ORGANICA", obj);
                ContextoDeObjs.ObjectStateManager.ChangeObjectState(obj, System.Data.EntityState.Modified);
                ContextoDeObjs.SaveChanges();
                return true;
            }
            catch (Exception)
            {
                return false;

            }
        }
        public bool Eliminar(PRM_UNI_ORGANICA obj)
        {
            try
            {
                ContextoDeObjs.AttachTo("PRM_UNI_ORGANICA", obj);
                ContextoDeObjs.DeleteObject(obj);
                ContextoDeObjs.SaveChanges();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
        public List<PRM_UNI_ORGANICA> listar()
        {
            List<PRM_UNI_ORGANICA> lista = new List<PRM_UNI_ORGANICA>();
            var q = from c in ContextoDeObjs.PRM_UNI_ORGANICA
                    select c;
            lista = q.ToList();
            return lista;
        }
    }
}
